Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
011ef82
fix(JS port): correct the worker<->host barrier ownership model (#5145)
shai-almog Jun 2, 2026
5d26163
fix(JS port): recover worker<->host response-cross + lost-response pa…
shai-almog Jun 2, 2026
8877282
feat(gpu): portable 3D/shader API skeleton (com.codename1.gpu)
shai-almog Jun 2, 2026
56d5276
feat(gpu): JavaSE simulator backend (software rasterizer)
shai-almog Jun 2, 2026
fe8a87e
test(gpu): 3D screenshot + animation tests in hellocodenameone
shai-almog Jun 2, 2026
26583b0
feat(gpu): Android (GLES2), iOS (Metal), JavaScript (WebGL) backends
shai-almog Jun 2, 2026
4b0337c
docs: developer guide chapter for the 3D graphics and shader API
shai-almog Jun 2, 2026
5ae7507
ci(JS port): upload delivered screenshots so goldens can be seeded fr…
shai-almog Jun 2, 2026
00baf08
fix(gpu): CI fixes - SpotBugs, vale docs, iOS animation-test hang
shai-almog Jun 2, 2026
a2565e9
fix(gpu): PMD + LanguageTool gates; skip 3D tests on time-boxed iOS/J…
shai-almog Jun 2, 2026
9317134
test(JS port #5145): drop obsolete HTML5 chunk-truncation self-skip (…
shai-almog Jun 3, 2026
1a320b1
fix(gpu): capture live 3D GPU scenes in screenshots (Android + JS), u…
shai-almog Jun 3, 2026
5da5b14
test(JS port #5145): seed StickyHeader x3 + StatusBar JS goldens + ra…
shai-almog Jun 3, 2026
bbb648a
test(gpu): multi-stage 3D animation grid; harden static captures vs c…
shai-almog Jun 3, 2026
6a24100
fix(gpu): iOS Metal cube invisible - adapt GL clip space to Metal
shai-almog Jun 3, 2026
82992dd
diag(gpu): temporary iOS Metal 3D draw/frame logging (CN1SS-prefixed)
shai-almog Jun 3, 2026
4e9cc5d
diag(gpu): CN1SS-prefixed iOS draw/frame logging to locate missing cube
shai-almog Jun 3, 2026
5ffdd7a
fix(JS port): serialize screenshot canvas read with a capture-scoped …
shai-almog Jun 3, 2026
c53cb62
diag(gpu): granular iOS draw step logging to locate NPE
shai-almog Jun 3, 2026
5fc4473
test(JS port): reseed TabsTheme_light golden with correct content
shai-almog Jun 3, 2026
a90c891
test(JS port): un-park ChatInput/ChatView screenshot tests
shai-almog Jun 3, 2026
2ecc688
diag(gpu): sub-step logging in iOS getOrCreatePipeline
shai-almog Jun 3, 2026
61b6943
Revert "test(JS port): un-park ChatInput/ChatView screenshot tests"
shai-almog Jun 3, 2026
3b417c5
fix(gpu): iOS Metal pipeline native NPE - add plain-form C symbol
shai-almog Jun 3, 2026
05bdeed
fix(JS port): give DualAppearance tests their full 30s deadline; un-p…
shai-almog Jun 3, 2026
930f743
test(JS port): reseed ChatInput/ChatView/TabsTheme_dark goldens with …
shai-almog Jun 3, 2026
042f4ec
fix(gpu): iOS pipeline native - real impl in plain symbol, _R_ delegates
shai-almog Jun 3, 2026
91d6ee2
test(JS port): reseed ToolbarTheme_dark golden with correct content
shai-almog Jun 3, 2026
119a0ff
fix(gpu): iOS Metal blank 3D - retain pipeline cache; strip diagnostics
shai-almog Jun 3, 2026
caac758
diag(JS port): dump pending host-call symbols + captureGate state on …
shai-almog Jun 3, 2026
850eb82
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 3, 2026
df68c54
perf(JS port): cache canvasContentScore per canvas to stop O(700) get…
shai-almog Jun 3, 2026
179bb60
diag(JS port): dump timed-wakeup details on frozen worker (wedge is N…
shai-almog Jun 3, 2026
a15bea8
diag(JS port): only dump frozen-worker state after a SUSTAINED (>=7.5…
shai-almog Jun 3, 2026
b1f9e88
fix(JS port): an uncaught green-thread exception must not halt the wh…
shai-almog Jun 4, 2026
68266e2
test(JS port): un-park Chart{CombinedXY,Transform,Rotated} screenshot…
shai-almog Jun 4, 2026
49211b2
Revert "test(JS port): un-park Chart{CombinedXY,Transform,Rotated} sc…
shai-almog Jun 4, 2026
0e80bb9
Merge remote-tracking branch 'origin/fix-jsport-barrier-model' into f…
shai-almog Jun 4, 2026
f1330bf
Merge remote-tracking branch 'origin/master' into fix-jsport-barrier-…
shai-almog Jun 4, 2026
6f3f2cd
fix(gpu): iOS Metal cube rendered inside-out - flip front-facing winding
shai-almog Jun 4, 2026
3c91ae1
Merge remote-tracking branch 'origin/fix-jsport-barrier-model' into f…
shai-almog Jun 4, 2026
4250b4a
Add com.codename1.gaming game development APIs
shai-almog Jun 4, 2026
d6940e6
Fix CI for the gaming package
shai-almog Jun 4, 2026
b258640
Fix JavaDoc build: pass sources to a single javadoc invocation via @a…
shai-almog Jun 4, 2026
c461d20
Fix SpotBugs findings for the gaming package
shai-almog Jun 4, 2026
810ff19
Fix SpotBugs findings in the port sound-pool backends
shai-almog Jun 4, 2026
af2c19e
Make the sprite engine GPU-native on com.codename1.gpu
shai-almog Jun 4, 2026
e017512
Merge remote-tracking branch 'origin/master' into add-gaming-package
shai-almog Jun 9, 2026
a4b4ece
Add 3D perspective + billboard sprites and 3D models to the gaming layer
shai-almog Jun 9, 2026
755c193
Developer guide: add a 3D and perspective section to the Game Develop…
shai-almog Jun 9, 2026
e712ca0
Add Gaming3DDemoSample: perspective billboards + a lit 3D model
shai-almog Jun 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/build_javadocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ find "$CN1_DIR/build/tempJavaSources" "$ROOT_DIR/Ports/CLDC11/src" -name "*.java
--add-script "$ROOT_DIR/maven/javadoc-resources/javadoc-highlight-init.js" \
--release 8 \
-exclude com.codename1.impl \
-exclude com.codename1.gaming.physics.box2d \
-Xdoclint:none \
-quiet \
-protected \
Expand Down
156 changes: 156 additions & 0 deletions CodenameOne/src/com/codename1/gaming/AnimatedSprite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
* Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.gaming;

import com.codename1.ui.Image;

/// A `Sprite` that cycles through a sequence of frames over time.
///
/// The animation advances in `#onUpdate(double)`, so adding it to a `Scene` whose
/// `Scene#update(double)` is called every frame (or calling `#onUpdate(double)`
/// directly) drives playback. By default it loops; set `#setLooping(boolean)` to
/// false to stop on the last frame.
public class AnimatedSprite extends Sprite {
private final Image[] frames;
private double frameDuration;
private double accumulator;
private int current;
private boolean looping = true;
private boolean playing = true;

/// Creates an animated sprite from an explicit array of frames.
///
/// #### Parameters
///
/// - `frames`: the frame images, played in order
///
/// - `secondsPerFrame`: how long each frame is shown, in seconds
public AnimatedSprite(Image[] frames, double secondsPerFrame) {
if (frames == null || frames.length == 0) {
throw new IllegalArgumentException("frames is empty");
}
this.frames = frames;
this.frameDuration = secondsPerFrame;
setImage(frames[0]);
}

/// Creates an animated sprite from frames pulled out of a `SpriteSheet`.
///
/// #### Parameters
///
/// - `sheet`: the source sprite sheet
///
/// - `frameIndices`: the linear frame indices to play, in order
///
/// - `secondsPerFrame`: how long each frame is shown, in seconds
public AnimatedSprite(SpriteSheet sheet, int[] frameIndices, double secondsPerFrame) {
if (frameIndices == null || frameIndices.length == 0) {
throw new IllegalArgumentException("frameIndices is empty");
}
Image[] f = new Image[frameIndices.length];
for (int i = 0; i < f.length; i++) {
f[i] = sheet.getFrame(frameIndices[i]);
}
this.frames = f;
this.frameDuration = secondsPerFrame;
setImage(f[0]);
}

protected void onUpdate(double deltaSeconds) {
if (!playing || frameDuration <= 0) {
return;
}
accumulator += deltaSeconds;
while (accumulator >= frameDuration) {
accumulator -= frameDuration;
current++;
if (current >= frames.length) {
if (looping) {
current = 0;
} else {
current = frames.length - 1;
playing = false;
break;
}
}
}
setImage(frames[current]);
}

/// Starts (or resumes) playback.
public void play() {
playing = true;
}

/// Pauses playback, keeping the current frame.
public void pause() {
playing = false;
}

/// Stops playback and rewinds to the first frame.
public void stop() {
playing = false;
current = 0;
accumulator = 0;
setImage(frames[0]);
}

public boolean isPlaying() {
return playing;
}

public boolean isLooping() {
return looping;
}

public void setLooping(boolean looping) {
this.looping = looping;
}

public double getFrameDuration() {
return frameDuration;
}

public void setFrameDuration(double secondsPerFrame) {
this.frameDuration = secondsPerFrame;
}

/// The index of the frame currently being shown.
public int getCurrentFrame() {
return current;
}

/// Jumps to the given frame index.
public void setCurrentFrame(int index) {
if (index < 0 || index >= frames.length) {
throw new IndexOutOfBoundsException("frame index " + index);
}
current = index;
accumulator = 0;
setImage(frames[index]);
}

public int getFrameCount() {
return frames.length;
}
}
Loading
Loading