Skip to content

Commit

Permalink
feat: the frantic run of the valorous rabbit demo game
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Oct 19, 2023
1 parent 87c0405 commit abb9f0a
Show file tree
Hide file tree
Showing 12 changed files with 2,383 additions and 95 deletions.
31 changes: 30 additions & 1 deletion apps/demo/src/app.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
@import 'nativescript-theme-core/scss/light';
@import 'nativescript-theme-core/scss/index';
@import 'nativescript-theme-core/scss/index';

.gameover {
font-weight: bold;
text-transform: uppercase;
font-size: 40;
//transform: translate(-100%, -100%);
opacity: 0;
transition: all 500ms ease-in-out;
text-align: center;
color: #ffc5a2;
&.show {
opacity: 1;
transform: translate(0%, 0%);
transition: all 500ms ease-in-out;
}
}


.distanceTitle {
text-transform:uppercase;
color:#ffa873;//100707;
font-size:12px;
letter-spacing:0.1px;
text-align:center;
}

.distanceValue {
font-size:40px;
}
5 changes: 1 addition & 4 deletions apps/demo/src/plugin-demos/canvas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
</ActionBar>
</Page.actionBar>




<GridLayout loaded="{{ gridLoaded }}" rows="*,*" columns="*,*" iosOverflowSafeArea="false" width="100%" height="100%">
<GridLayout backgroundColor="red" rows="*" columns="*" loaded="{{ gridLoaded }}" iosOverflowSafeArea="false" width="100%" height="100%">

<!-- <ui:Dom rowSpan="2" colSpan="2"> -->

Expand Down
6 changes: 1 addition & 5 deletions packages/canvas/Canvas/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,8 @@ export class Canvas extends CanvasBase {

opts['fontColor'] = this.parent?.style?.color?.android || -16777216;

// this._canvas.initContext(type, opts.alpha, opts.antialias, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.desynchronized, opts.xrCompatible);

const ctx = this._canvas.create2DContext(opts.alpha, opts.antialias, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible, opts.fontColor);
this._2dContext = new (CanvasRenderingContext2D as any)(ctx);
//this._2dContext = new (CanvasRenderingContext2D as any)(this._canvas, opts);

// // @ts-ignore
(this._2dContext as any)._canvas = this;
// @ts-ignore
Expand All @@ -304,7 +300,7 @@ export class Canvas extends CanvasBase {
this._layoutNative();
const opts = Object.assign({ version: 'v1' }, Object.assign(defaultOpts, this._handleContextOptions(type, options)));

this._canvas.initContext(type, true, false, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible);
this._canvas.initContext(type, opts.alpha, false, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible);
this._webglContext = new (WebGLRenderingContext as any)(this._canvas, opts);
(this._webglContext as any)._canvas = this;
this._webglContext._type = 'webgl';
Expand Down
1 change: 0 additions & 1 deletion packages/canvas/WebGL/WebGLRenderingContext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
//direction = 1;
}


this._context = global.CanvasModule.createWebGLContext(contextOptions, ctx, Screen.mainScreen.scale, -16777216, Screen.mainScreen.scale * 160, direction);
} else {
this._context = context;
Expand Down
Binary file modified packages/canvas/platforms/android/canvas-release.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ class NSCCanvas : FrameLayout {
Surface
}


private var didUpscale = false
var upscale: Boolean = false
set(value) {
field = value
didUpscale = true;
updateParams(width, height)
}

Expand Down Expand Up @@ -406,6 +407,9 @@ class NSCCanvas : FrameLayout {
}

private fun updateParams(w: Int, h: Int) {
if (!didUpscale) {
return
}
if (upscale) {
val density = resources.displayMetrics.density
if (surfaceType == SurfaceType.Surface) {
Expand All @@ -428,9 +432,10 @@ class NSCCanvas : FrameLayout {
ViewGroup.LayoutParams.MATCH_PARENT
)
}
clipChildren = false
clipToPadding = false
clipChildren = true
clipToPadding = true
ignorePixelScaling = false
didUpscale = false
}
}

Expand All @@ -454,11 +459,11 @@ class NSCCanvas : FrameLayout {
nativeUpdate2DSurface(it, native2DContext)
}
} ?: run {
nativeUpdateGLNoSurface(this.drawingBufferWidth, this.drawingBufferWidth, nativeGL)
nativeUpdateGLNoSurface(this.drawingBufferWidth, this.drawingBufferHeight, nativeGL)
if (is2D) {
nativeUpdate2DSurfaceNoSurface(
this.drawingBufferWidth,
this.drawingBufferWidth,
this.drawingBufferHeight,
native2DContext
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::cell::{Ref, RefCell, RefMut};
use std::cell::RefCell;
use std::ffi::CString;
use std::num::NonZeroU32;
use std::rc::Rc;
Expand All @@ -14,7 +14,6 @@ use glutin::display::{GetGlDisplay, RawDisplay};
use glutin::prelude::GlSurface;
use glutin::prelude::*;
use glutin::surface::{PbufferSurface, PixmapSurface, SwapInterval, WindowSurface};
use once_cell::sync::Lazy;
use raw_window_handle::{
AppKitDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle,
};
Expand Down Expand Up @@ -475,13 +474,13 @@ impl GLContext {

let alpha_requested = context_attrs.get_alpha();

let mut alpha_size = if alpha_requested { 8u8 } else { 0u8 };
let mut stencil_size = if context_attrs.get_stencil() {
let alpha_size = if alpha_requested { 8u8 } else { 0u8 };
let stencil_size = if context_attrs.get_stencil() {
8u8
} else {
0u8
};
let mut depth_size = if context_attrs.get_depth() { 16u8 } else { 0u8 };
let depth_size = if context_attrs.get_depth() { 16u8 } else { 0u8 };

if multi_sample {
if supports_transparency == alpha_requested
Expand Down
17 changes: 17 additions & 0 deletions tools/demo/canvas-three/assets/js/libs/TweenMax.min.js

Large diffs are not rendered by default.

Binary file not shown.
Loading

0 comments on commit abb9f0a

Please sign in to comment.